<?php
//No direct access
defined('_JEXEC') or die('Restricted access');
?>
<div id="ownservices">
	<div id="mainmenuownservice"><?php echo MenuHelper::nav(); ?></div>
	<div id="mainownservice">
	<h3>
		<?php 
			if($this->row->id) { 
				echo JText::_('OWNSERVICE_EDIT_BRANCH'); 
			} else { 
				echo JText::_('OWNSERVICE_NEW_BRANCH'); 
			} 
		?>
	</h3>
	<hr />
	<?php $row = $this->row; ?>
	<script language="javascript" type="text/javascript">
		<!--
			function submitbutton(pressbutton)
			{
				var form = document.adminForm;
				if (pressbutton == 'cancel') {
					submitform( pressbutton );
					return;

				}
				if(form.name.value == "") {
					alert( "<?php echo JText::_( 'OWNSERVICE_PLEASE_INPUT_BRANCHNAME', true ); ?>" );
				}/*else if(form.abn.value == "") {
					alert( "<?php echo JText::_( 'OWNSERVICE_PLEASE_INPUT_ABN', true ); ?>" );
				}*/else if (form.address.value == ""){
					alert( "<?php echo JText::_( 'OWNSERVICE_PLEASE_INPUT_ADDRESS', true ); ?>" );
				} else if (form.city.value == ""){
					alert( "<?php echo JText::_( 'OWNSERVICE_PLEASE_INPUT_CITY', true ); ?>" );
				} else if (form.state.value == ""){
					alert( "<?php echo JText::_( 'OWNSERVICE_PLEASE_INPUT_STATE', true ); ?>" );
				} else if (form.postcode.value == ""){
					alert( "<?php echo JText::_( 'OWNSERVICE_PLEASE_INPUT_POSTCODE', true ); ?>" );
				} else if (form.country.value == ""){
					alert( "<?php echo JText::_( 'OWNSERVICE_PLEASE_INPUT_COUNTRY', true ); ?>" );
				} else {
					submitform( pressbutton );
				}
			}
		//-->
	</script>
	<form action="<?php echo JRoute::_('index.php?option=com_ownservice'); ?>" method="post" name="adminForm">
		<table class="admintable">
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_BRANCHNAME'); ?>: <span class="red">*</span></td>
				<td>
					<input type="text" name="name" value="<?php echo $row->name; ?>" class="inputbox" size="50" />
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_BRANCH_CODE'); ?>: <span class="red">*</span></td>
				<td>
					<input type="text" name="code" value="<?php echo $row->code; ?>" class="inputbox" size="20" />
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('ABN'); ?>:</td>
				<td>
					<input type="text" name="abn" id="abn" value="<?php echo $row->abn; ?>" class="inputbox" size="50" />
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_PUBLISHED'); ?>:</td>
				<td>
					<?php
						$html = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published );
						echo $html;
					?>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_ADDRESS'); ?>: <span class="red">*</span></td>
				<td>
					<textarea cols="47" rows="3" name="address"><?php echo $row->address; ?></textarea>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_CITY'); ?>: <span class="red">*</span></td>
				<td>
					<input type="text" name="city" value="<?php echo $row->city; ?>" class="inputbox" size="50" />
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_STATE'); ?>: <span class="red">*</span></td>
				<td>
					<input type="text" name="state" value="<?php echo $row->state; ?>" class="inputbox" size="50" />
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_POSTCODE'); ?>: <span class="red">*</span></td>
				<td>
					<input type="text" name="postcode" value="<?php echo $row->postcode; ?>" class="inputbox" size="20" />
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_COUNTRY'); ?>: <span class="red">*</span></td>
				<td>
					<?php echo $this->lists['country']; ?>
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_PHONE'); ?>: </td>
				<td>
					<input type="text" name="phone" value="<?php echo $row->phone; ?>" class="inputbox" size="20" />
				</td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_EMAIL'); ?>: </td>
				<td>
					<input type="text" name="email" value="<?php echo $row->email; ?>" class="inputbox" size="50" />
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center"><hr /></td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('AGENT'); ?></td>
				<td>
					<?php echo $this->lists['branch']; ?>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center"><hr /></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><hr /></td>
			</tr>
			<tr>
				<td class="key"><?php echo JText::_('OWNSERVICE_ADVERTISING'); ?>: </td>
				<td>
					<?php echo $this->editor->display( 'advertising',  $row->advertising , '100%', '300', '75', '20',array('pagebreak', 'readmore') ) ; ?>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center"><hr /></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
				<input type="button" name="save" value="<?php echo JText::_('OWNSERVICE_SAVE'); ?>" onClick="javascript: submitbutton('save')" />
				<input type="button" name="cancel" value="<?php echo JText::_('OWNSERVICE_CANCEL'); ?>" onClick="javascript: submitbutton('cancel')" />
				</td>
			</tr>
		</table>
		<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="option" value="com_ownservice" />
		<input type="hidden" name="task" value="save" />
		<input type="hidden" name="Itemid" value="<?php echo JRequest::getVar('Itemid'); ?>" />
		<input type="hidden" name="controller" value="branch" />
		<input type="hidden" name="view" value="branch" />
		<?php echo JHTML::_( 'form.token' ); ?>
	</form>
	</div>
</div>